<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}

$idemployee=$_GET["idemployee"];

$listreference=$_SESSION['listreference1'];
$namereference=$_SESSION['namereference1'];
$i=$_SESSION['slreference1'];



$co=0;
for ($j=0;$j<$i;$j++){
	if ($listreference[$j]==$idemployee)
		$co=1;
}
if($co==0){
	include '../operations/connection.php';
	mysql_query("INSERT INTO `list_sendmail` (`employee_id`, `employee_id_sendmail`) VALUES ('".$_SESSION['IDEmployee']."', '$idemployee')");
	//echo "INSERT INTO `list_sendmail` (`employee_id`, `employee_id_sendmail`) VALUES ('".$_SESSION['IDEmployee']."', '$idemployee')";
  	$sql="SELECT IDEmployee,FullName FROM employee WHERE IDEmployee='$idemployee'";
  	$query=mysql_query($sql);
  	$row = mysql_fetch_array($query);
  	
  	$namereference[$i]=$row[FullName];
	$listreference[$i]=$idemployee;
	$i=$i+1;
}

$_SESSION['namereference1']=$namereference;
$_SESSION['listreference1']=$listreference;
$_SESSION['slreference1']=$i;

echo "<table border='1' class='table_th' style='height:22px;' cellspacing='0' width='100%'>
<tr style='background-color:#EEE;'>
<td colspan='2'>List Send Mail</td>
</tr>";
for ($j=0;$j<$i;$j++){
  echo "<tr >";
  echo "<td>" .$namereference[$j]. "</td>";
  echo "<td width='20'><a onclick='rmReference1(".$listreference[$j].")'><img src='images/del.png' /></a></td>";
  echo "</tr>";
}
echo "</table>";
?>